<?php

use App\Models\RecruitmentAuthor;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
//注册后台用户
Route::post('create', [\App\Http\Controllers\Admin\SystemUserController::class,"create"]);
Route::post('get_user_by_phone', [\App\Http\Controllers\Admin\SystemUserController::class,"getUserByPhone"]);
//登录
Route::post('login',  [\App\Http\Controllers\Admin\LoginController::class,'login']);
Route::post('login_by_code',  [\App\Http\Controllers\Admin\LoginController::class,'loginByCode']);
//获取验证码
Route::post('sms_code',  [\App\Http\Controllers\Admin\LoginController::class,'smsCode']);
//登出
Route::post('logout', [\App\Http\Controllers\Admin\LoginController::class,'logout'])->middleware('auth:sanctum');
//权限管理
Route::middleware('auth:sanctum')->prefix('permission')->group(function(){

    Route::post('module/list',[\App\Http\Controllers\Admin\ModuleController::class,'list']);
    Route::post('module/store',[\App\Http\Controllers\Admin\ModuleController::class,'store']);
    Route::post('module/edit',[\App\Http\Controllers\Admin\ModuleController::class,'edit']);
    Route::post('module/update',[\App\Http\Controllers\Admin\ModuleController::class,'update']);
    Route::post('module/delete',[\App\Http\Controllers\Admin\ModuleController::class,'destory']);

    Route::post('role/list',[\App\Http\Controllers\Admin\RoleController::class,'list']);
    Route::post('role/store',[\App\Http\Controllers\Admin\RoleController::class,'store']);
    Route::post('role/edit',[\App\Http\Controllers\Admin\RoleController::class,'edit']);
    Route::post('role/update',[\App\Http\Controllers\Admin\RoleController::class,'update']);
    Route::post('role/delete',[\App\Http\Controllers\Admin\RoleController::class,'destory']);

    Route::post('system_user/remove_user_role',[\App\Http\Controllers\Admin\SystemUserController::class,'deleteRole']);


    Route::post('list',[\App\Http\Controllers\Admin\PermissionController::class,'list']);
    Route::post('create',[\App\Http\Controllers\Admin\PermissionController::class,'create']);
    Route::post('store',[\App\Http\Controllers\Admin\PermissionController::class,'store']);
    Route::post('edit',[\App\Http\Controllers\Admin\PermissionController::class,'edit']);
    Route::post('update',[\App\Http\Controllers\Admin\PermissionController::class,'update']);
    Route::post('destory',[\App\Http\Controllers\Admin\PermissionController::class,'destory']);

    //角色分配权限方法
    Route::post('role_has_permission',[\App\Http\Controllers\Admin\RoleHasPermissionController::class,'roleHasPermission']);
    Route::post('role_resolve_permission',[\App\Http\Controllers\Admin\RoleHasPermissionController::class,'roleResolvePermission']);
    Route::post('role_owner_permission',[\App\Http\Controllers\Admin\RoleHasPermissionController::class,'roleOwnerPermission']);
    Route::post('role_get_permission',[\App\Http\Controllers\Admin\RoleHasPermissionController::class,'roleGetPermission']);
    //直接获取用户权限
    Route::post('get_all_permission',[\App\Http\Controllers\Admin\RoleHasPermissionController::class,'getUserAllPermission']);
    Route::post('edit_user_permission',[\App\Http\Controllers\Admin\RoleHasPermissionController::class,'editUserPermission']);
    Route::post('update_user_permission',[\App\Http\Controllers\Admin\RoleHasPermissionController::class,'updateUserPermissions']);

});
Route::middleware('auth:sanctum')->group(function () {
    //控制面板数据
    Route::post('dashboard/list', [\App\Http\Controllers\Admin\DashboardController::class,"list"]);
    //用户列表
    Route::post('list', [\App\Http\Controllers\Admin\SystemUserController::class,"list"]);
    //修改密码
    Route::post('update_passwd', [\App\Http\Controllers\Admin\SystemUserController::class,"updatePassword"]);
    Route::post('update', [\App\Http\Controllers\Admin\SystemUserController::class,"update"]);
    //编辑用户
    Route::post('edit', [\App\Http\Controllers\Admin\SystemUserController::class,"edit"]);
    //用户分配角色
    Route::post('role', [\App\Http\Controllers\Admin\SystemUserController::class,"role"]);
    //获取用户角色
    Route::post('get_role', [\App\Http\Controllers\Admin\SystemUserController::class,"getRole"]);

//部门管理
    Route::post('department/list', [\App\Http\Controllers\Admin\DepartmentController::class,"list"]);
    Route::post('department/store', [\App\Http\Controllers\Admin\DepartmentController::class,"store"]);
    Route::post('department/update', [\App\Http\Controllers\Admin\DepartmentController::class,"update"]);
    Route::post('department/edit', [\App\Http\Controllers\Admin\DepartmentController::class,"edit"]);
    //部门权限管理
    Route::post('department_has_permission/store', [\App\Http\Controllers\Admin\DepartmentPermissionController::class,"store"]);
    Route::post('department_has_permission/get', [\App\Http\Controllers\Admin\DepartmentPermissionController::class,"DepartmentOwnerPermission"]);
    //基础配置
    Route::post('config/list',[\App\Http\Controllers\ConfigController::class,'list']);
    Route::post('config/store',[\App\Http\Controllers\ConfigController::class,'store']);
    Route::post('config/edit',[\App\Http\Controllers\ConfigController::class,'edit']);
    Route::post('config/update',[\App\Http\Controllers\ConfigController::class,'update']);
});


